Performance-based hardware emulation in an on-demand network code execution system

ABSTRACT

Systems and methods are described for providing performance-based hardware emulation in an on-demand network code execution system. A user may generate a task on the system by submitting code. The system may determine, based on the code or its execution, that the code executes more efficiently if certain functionality is available, such as an extension to a processor&#39;s instruction set. The system may further determine that it can provide the needed functionality using various computing resources, which may include physical hardware, emulated hardware (e.g., a virtual machine), or combinations thereof. The system may then determine and provide a set of computing resources to use when executing the user-submitted code, which may be based on factors such as availability, cost, estimated performance, desired performance, or other criteria. The system may also migrate code from one set of computing resources to another, and may analyze demand and project future computing resource needs.

BACKGROUND

Computing devices can utilize communication networks to exchange data.Companies and organizations operate computer networks that interconnecta number of computing devices to support operations or provide servicesto third parties. The computing systems can be located in a singlegeographic location or located in multiple, distinct geographiclocations (e.g., interconnected via private or public communicationnetworks). Specifically, hosted computing environments or dataprocessing centers, generally referred to herein as “data centers,” mayinclude a number of interconnected computing systems to providecomputing resources to users of the data center. The data centers may beprivate data centers operated on behalf of an organization, or publicdata centers operated on behalf, or for the benefit of, the generalpublic.

To facilitate increased utilization of data center resources,virtualization technologies allow a single physical computing device tohost one or more instances of virtual machines that appear and operateas independent computing devices to users of a data center. Withvirtualization, the single physical computing device can create,maintain, delete, or otherwise manage virtual machines in a dynamicmanner. In turn, users can request computing resources from a datacenter, such as single computing devices or a configuration of networkedcomputing devices, and be provided with varying numbers of virtualmachine resources.

In some scenarios, a user can request that a data center providecomputing resources to execute a particular task. The task maycorrespond to a set of computer-executable instructions, which the datacenter may then execute on behalf of the user. The data center may thusfurther facilitate increased utilization of data center resources.

BRIEF DESCRIPTION OF THE DRAWINGS

Throughout the drawings, reference numbers may be re-used to indicatecorrespondence between referenced elements. The drawings are provided toillustrate example embodiments described herein and are not intended tolimit the scope of the disclosure.

FIG. 1 is a block diagram depicting an illustrative environment in whichan on-demand code execution system can execute tasks corresponding tocode, which may be submitted by users of the on-demand code executionsystem, and can determine which computing resources to use to facilitateexecution of the submitted code.

FIG. 2 depicts a general architecture of a computing device providing anemulation performance analysis system that is configured to determinethe computing resources used to facilitate execution of tasks on theon-demand code execution system of FIG. 1.

FIG. 3 is a flow diagram depicting illustrative interactions forsubmitting code corresponding to a task to the on-demand code executionsystem of FIG. 1, and for the on-demand code execution system to analyzethe code and determine a set of computing resources that may be used tofacilitate execution.

FIG. 4 is a flow diagram depicting illustrative interactions for theon-demand code execution system of FIG. 1 to analyze performance metricsassociated with the execution of code using a particular set ofcomputing resources, determine whether an alternate set of computingresources is available and would be preferable, and if so migrate thecode execution to the alternate set of computing resources.

FIG. 5 is a flow chart depicting an illustrative routine for analyzingsubmitted code to determine a set of resources that may be used tofacilitate execution of the code on the on-demand code execution systemof FIG. 1.

FIG. 6 is a flow chart depicting an illustrative routine for analyzingthe performance of executing code with a particular set of resources onthe on-demand code execution system of FIG. 1 and migrating code toalternate sets of resources as needed.

DETAILED DESCRIPTION

Generally described, aspects of the present disclosure relate to anon-demand code execution system. The on-demand code execution systemenables rapid execution of code, which may be supplied by users of theon-demand code execution system. More specifically, embodiments of thepresent disclosure relate to improving the performance of an on-demandcode execution system that is implemented using various computingresources. As described in detail herein, the on-demand code executionsystem may provide a network-accessible service enabling users to submitor designate computer-executable code to be executed by virtual machineinstances on the on-demand code execution system. Each set of code onthe on-demand code execution system may define a “task,” and implementspecific functionality corresponding to that task when executed on avirtual machine instance of the on-demand code execution system.Individual implementations of the task on the on-demand code executionsystem may be referred to as an “execution” of the task (or a “taskexecution”). The on-demand code execution system can further enableusers to trigger execution of a task based on a variety of potentialevents, such as detecting new data at a network-based storage system,transmission of an application programming interface (“API”) call to theon-demand code execution system, or transmission of a speciallyformatted hypertext transport protocol (“HTTP”) packet to the on-demandcode execution system. Thus, users may utilize the on-demand codeexecution system to execute any specified executable code “on-demand,”without requiring configuration or maintenance of the underlyinghardware or infrastructure on which the code is executed. Further, theon-demand code execution system may be configured to execute tasks in arapid manner (e.g., in under 100 milliseconds [ms]), thus enablingexecution of tasks in “real-time” (e.g., with little or no perceptibledelay to an end user).

The on-demand code execution system may instantiate virtual machineinstances to execute the specified tasks on demand. The virtual machineinstances may be provisioned with virtual processors or other computingresources, which provide functionality that the user-specifiedexecutable code may require during execution. For example, a virtualmachine instance may be provisioned with a processor that facilitates oraccelerates operations that are frequently used by neural networks. Theprocessor may implement, for example, a particular instruction set (oran extension to an instruction set) that relates to these operations. Insome embodiments, the instruction set may also be implemented by theunderlying hardware processor of the physical computing device on whichthe virtual machine instance is instantiated. In other embodiments, thevirtual machine instance may emulate a processor that implements aparticular instruction set, and the virtual machine instance may beinstantiated using a physical processor that does not implement theinstruction set. The virtual machine instance may thus translateinstructions implemented by the virtual processor into instructions thatare implemented by the physical processor, with varying effects onperformance or efficiency.

The on-demand code execution system may utilize a pool of computingresources to execute user-submitted code. The pool may include resourcesthat vary in terms of functionality, and the demand for resources thatimplement particular functionality may exceed the available supply ofthose resources. For example, several user-submitted tasks may requireor prefer a processor that implements a particular instruction set, butonly a limited number of these processors may be available. In someembodiments, excess demand for resources that implement particularfunctionality may be met with resources that emulate the functionality.For example, a virtual machine instance may be instantiated thatemulates the processor, as discussed above, and the on-demand codeexecution system may assign user-submitted tasks to the physical andvirtual resources based on factors such as relative performance. Forexample, a first user-submitted task may be able to execute withacceptable performance on an emulated processor, while a seconduser-submitted task may execute very slowly or not at all. The on-demandcode execution system may thus prioritize the allocation of scarceresources based on assessments of whether the functionality is requiredor merely desirable in order to execute a particular task, and mayfurther prioritize based on the relative performance of different tasks,such that the tasks that benefit the most from the functionality receiveit.

In some embodiments, a virtual machine instance instantiated on a fastphysical processor may outperform a virtual or physical computing devicethat uses a slower processor, even if the slower processor providesfunctionality that the faster processor does not. For example, an olderprocessor with a particular instruction set may be emulated in a virtualmachine instance that is instantiated on a newer processor without theinstruction set, and the performance gain realized by executing on thenewer processor may more than offset the performance overhead associatedwith emulated the processor or instruction set. It will thus beunderstood that the on-demand code execution system is not limited tophysical processors when determining a recommended set of computingresources, and that virtual emulation of a physical processor mayprovide superior performance.

As will be appreciated by one of skill in the art in light of thepresent disclosure, the embodiments disclosed herein improves theability of computing systems, such as on-demand code execution systems,to execute code in an efficient manner. Moreover, the presentlydisclosed embodiments address technical problems inherent withincomputing systems; specifically, the limited nature of computingresources with which to execute code, the resource overhead associatedwith provisioning virtual machines to facilitate code execution, and theinefficiencies caused by provisioning functionality that is not utilized(or not provisioning functionality that would be utilized if available).These technical problems are addressed by the various technicalsolutions described herein, including the provisioning of an executionenvironment based on the functionality required by the code to beexecuted. Thus, the present disclosure represents an improvement onexisting data processing systems and computing systems in general.

The on-demand code execution system may include a virtual machineinstance manager configured to receive user code (threads, programs,etc., composed in any of a variety of programming languages) and executethe code in a highly scalable, low latency manner, without requiringuser configuration of a virtual machine instance. Specifically, thevirtual machine instance manager can, prior to receiving the user codeand prior to receiving any information from a user regarding anyparticular virtual machine instance configuration, create and configurevirtual machine instances according to a predetermined set ofconfigurations, each corresponding to any one or more of a variety ofrun-time environments. Thereafter, the virtual machine instance managerreceives user-initiated requests to execute code, and identifies apre-configured virtual machine instance to execute the code based onconfiguration information associated with the request. The virtualmachine instance manager can further allocate the identified virtualmachine instance to execute the user's code at least partly by creatingand configuring containers inside the allocated virtual machineinstance, and provisioning the containers with code of the task as wellas an dependency code objects. Various embodiments for implementing avirtual machine instance manager and executing user code on virtualmachine instances is described in more detail in U.S. Pat. No.9,323,556, entitled “PROGRAMMATIC EVENT DETECTION AND MESSAGE GENERATIONFOR REQUESTS TO EXECUTE PROGRAM CODE,” and filed Sep. 30, 2014 (the“'556 Patent”), the entirety of which is hereby incorporated byreference.

As used herein, the term “virtual machine instance” is intended to referto an execution of software or other executable code that emulateshardware to provide an environment or platform on which software mayexecute (an “execution environment”). Virtual machine instances aregenerally executed by hardware devices, which may differ from thephysical hardware emulated by the virtual machine instance. For example,a virtual machine may emulate a first type of processor and memory whilebeing executed on a second type of processor and memory. Thus, virtualmachines can be utilized to execute software intended for a firstexecution environment (e.g., a first operating system) on a physicaldevice that is executing a second execution environment (e.g., a secondoperating system). In some instances, hardware emulated by a virtualmachine instance may be the same or similar to hardware of an underlyingdevice. For example, a device with a first type of processor mayimplement a plurality of virtual machine instances, each emulating aninstance of that first type of processor. Thus, virtual machineinstances can be used to divide a device into a number of logicalsub-devices (each referred to as a “virtual machine instance”). Whilevirtual machine instances can generally provide a level of abstractionaway from the hardware of an underlying physical device, thisabstraction is not required. For example, assume a device implements aplurality of virtual machine instances, each of which emulate hardwareidentical to that provided by the device. Under such a scenario, eachvirtual machine instance may allow a software application to executecode on the underlying hardware without translation, while maintaining alogical separation between software applications running on othervirtual machine instances. This process, which is generally referred toas “native execution,” may be utilized to increase the speed orperformance of virtual machine instances. Other techniques that allowdirect utilization of underlying hardware, such as hardware pass-throughtechniques, may be used as well.

While a virtual machine executing an operating system is describedherein as one example of an execution environment, other executionenvironments are also possible. For example, tasks or other processesmay be executed within a software “container,” which provides a runtimeenvironment without itself providing virtualization of hardware.Containers may be implemented within virtual machines to provideadditional security, or may be run outside of a virtual machineinstance.

Although example embodiments are described herein with regard toprocessor instruction sets, it will be understood that the presentdisclosure is not limited to any particular computing resource orfunctionality. For example, code may be analyzed to determine that itspends a significant amount of time waiting for a storage device to reador write information, and a determination may be made to provide ahigher-speed data store (e.g., a memory cache or solid state device) tofacilitate more efficient execution of the code. As a further example,code or performance metrics may be analyzed to determine that providinga particular graphics processing unit (“GPU”) would facilitate executionof the user-submitted task, and the identified GPU may be provided oremulated. As a still further example, code may be analyzed to determinethat it is optimized for a particular type of memory, such asnon-volatile random access memory (“NVRAM”) or dynamic random accessmemory (“DRAM”), and the particular type of memory may be supplied. Theexample embodiments are thus understood to be illustrative and notlimiting.

In some embodiments, a user may submit code that requires particularfunctionality, or code that runs more efficiently if certainfunctionality is provided, without being aware of the dependency. Forexample, the user-submitted code may make use of a third-party library,and the library may require the functionality or make extensive use ofit if available. In other embodiments, the user may be aware thatparticular functionality is needed, but may not know whether theon-demand code execution system provides the functionality or if sowhether the functionality is currently available. By implementing theembodiments described herein, the on-demand code execution systemaddresses these issues and allows the user to submit code withoutidentifying the functionality it requires, and without having tospecifically request that the on-demand code execution system providethe functionality.

Embodiments of the disclosure will now be described with reference tothe accompanying figures, wherein like numerals refer to like elementsthroughout. The terminology used in the description presented herein isnot intended to be interpreted in any limited or restrictive manner,simply because it is being utilized in conjunction with a detaileddescription of certain specific embodiments of the invention.Furthermore, embodiments of the invention may include several novelfeatures, no single one of which is solely responsible for its desirableattributes or which is essential to practicing the inventions hereindescribed.

FIG. 1 is a block diagram of an illustrative operating environment 100in which an on-demand code execution system 110 may operate based oncommunication with user computing devices 102, auxiliary services 106,and network-based data storage services 108. In general, the usercomputing devices 102 can be any computing device such as a desktop,laptop or tablet computer, personal computer, wearable computer, server,personal digital assistant (PDA), hybrid PDA/mobile phone, mobile phone,electronic book reader, set-top box, voice command device, camera,digital media player, and the like. The on-demand code execution system110 may provide the user computing devices 102 with one or more userinterfaces, command-line interfaces (CLIs), application programinginterfaces (APIs), and/or other programmatic interfaces for generatingand uploading user-executable code (e.g., including metadata identifyingdependency code objects for the uploaded code), invoking theuser-provided code (e.g., submitting a request to execute the user codeson the on-demand code execution system 110), scheduling event-based jobsor timed jobs, tracking the user-provided code, and/or viewing otherlogging or monitoring information related to their requests and/or usercodes. Although one or more embodiments may be described herein as usinga user interface, it should be appreciated that such embodiments may,additionally or alternatively, use any CLIs, APIs, or other programmaticinterfaces.

The illustrative environment 100 further includes one or morenetwork-based data storage services 108, configured to enable theon-demand code execution system 110 to store and retrieve data from oneor more persistent or substantially persistent data sources.Illustratively, the network-based data storage services 108 may enablethe on-demand code execution system 110 to store informationcorresponding to a task, such as code or metadata, to store additionalcode objects representing dependencies of tasks, to retrieve data to beprocessed during execution of a task, and to store information (e.g.,results) regarding that execution. The network-based data storageservices 108 may represent, for example, a relational or non-relationaldatabase. In another example, the network-based data storage services108 may represent a network-attached storage (NAS), configured toprovide access to data arranged as a file system. The network-based datastorage services 108 may further enable the on-demand code executionsystem 110 to query for and retrieve information regarding data storedwithin the on-demand code execution system 110, such as by querying fora number of relevant files or records, sizes of those files or records,file or record names, file or record creation times, etc. In someinstances, the network-based data storage services 108 may provideadditional functionality, such as the ability to separate data intological groups (e.g., groups associated with individual accounts, etc.).While shown as distinct from the auxiliary services 106, thenetwork-based data storage services 108 may in some instances alsorepresent a type of auxiliary service 106.

The user computing devices 102, auxiliary services 106, andnetwork-based data storage services 108 may communicate with theon-demand code execution system 110 via a network 104, which may includeany wired network, wireless network, or combination thereof. Forexample, the network 104 may be a personal area network, local areanetwork, wide area network, over-the-air broadcast network (e.g., forradio or television), cable network, satellite network, cellulartelephone network, or combination thereof. As a further example, thenetwork 104 may be a publicly accessible network of linked networks,possibly operated by various distinct parties, such as the Internet. Insome embodiments, the network 104 may be a private or semi-privatenetwork, such as a corporate or university intranet. The network 104 mayinclude one or more wireless networks, such as a Global System forMobile Communications (GSM) network, a Code Division Multiple Access(CDMA) network, a Long Term Evolution (LTE) network, or any other typeof wireless network. The network 104 can use protocols and componentsfor communicating via the Internet or any of the other aforementionedtypes of networks. For example, the protocols used by the network 104may include Hypertext Transfer Protocol (HTTP), HTTP Secure (HTTPS),Message Queue Telemetry Transport (MQTT), Constrained ApplicationProtocol (CoAP), and the like. Protocols and components forcommunicating via the Internet or any of the other aforementioned typesof communication networks are well known to those skilled in the artand, thus, are not described in more detail herein.

The on-demand code execution system 110 is depicted in FIG. 1 asoperating in a distributed computing environment including severalcomputer systems that are interconnected using one or more computernetworks (not shown in FIG. 1). The on-demand code execution system 110could also operate within a computing environment having a fewer orgreater number of devices than are illustrated in FIG. 1. Thus, thedepiction of the on-demand code execution system 110 in FIG. 1 should betaken as illustrative and not limiting to the present disclosure. Forexample, the on-demand code execution system 110 or various constituentsthereof could implement various Web services components, hosted or“cloud” computing environments, and/or peer to peer networkconfigurations to implement at least a portion of the processesdescribed herein.

Further, the on-demand code execution system 110 may be implementeddirectly in hardware or software executed by hardware devices and may,for instance, include one or more physical or virtual serversimplemented on physical computer hardware configured to execute computerexecutable instructions for performing various features that will bedescribed herein. The one or more servers may be geographicallydispersed or geographically co-located, for instance, in one or moredata centers. In some instances, the one or more servers may operate aspart of a system of rapidly provisioned and released computingresources, often referred to as a “cloud computing environment.”

In the example of FIG. 1, the on-demand code execution system 110 isillustrated as connected to the network 104. In some embodiments, any ofthe components within the on-demand code execution system 110 cancommunicate with other components of the on-demand code execution system110 via the network 104. In other embodiments, not all components of theon-demand code execution system 110 are capable of communicating withother components of the virtual environment 100. In one example, onlythe frontend 120 (which may in some instances represent multiplefrontends 120) may be connected to the network 104, and other componentsof the on-demand code execution system 110 may communicate with othercomponents of the environment 100 via the frontends 120.

In FIG. 1, users, by way of user computing devices 102, may interactwith the on-demand code execution system 110 to provide executable code,and establish rules or logic defining when and how such code should beexecuted on the on-demand code execution system 110, thus establishing a“task.” For example, a user may wish to run a piece of code inconnection with a web or mobile application that the user has developed.One way of running the code would be to acquire virtual machineinstances from service providers who provide infrastructure as aservice, configure the virtual machine instances to suit the user'sneeds, and use the configured virtual machine instances to run the code.In order to avoid the complexity of this process, the user mayalternatively provide the code to the on-demand code execution system110, and request that the on-demand code execution system 110 executethe code. The on-demand code execution system 110 can handle theacquisition and configuration of compute capacity (e.g., containers,instances, etc., which are described in greater detail below) based onthe code execution request, and execute the code using the computecapacity. The on-demand code execution system 110 may automaticallyscale up and down based on the volume, thereby relieving the user fromthe burden of having to worry about over-utilization (e.g., acquiringtoo little computing resources and suffering performance issues) orunder-utilization (e.g., acquiring more computing resources thannecessary to run the codes, and thus overpaying). In accordance withembodiments of the present disclosure, and as described in more detailbelow, the on-demand code execution system 110 may configure the virtualmachine instances with customized operating systems to execute theuser's code more efficiency and reduce utilization of computingresources.

To enable interaction with the on-demand code execution system 110, thesystem 110 includes one or more frontends 120, which enable interactionwith the on-demand code execution system 110. In an illustrativeembodiment, the frontends 120 serve as a “front door” to the otherservices provided by the on-demand code execution system 110, enablingusers (via user computing devices 102) to provide, request execution of,and view results of computer executable code. The frontends 120 includea variety of components to enable interaction between the on-demand codeexecution system 110 and other computing devices. For example, eachfrontend 120 may include a request interface providing user computingdevices 102 with the ability to upload or otherwise communicationuser-specified code to the on-demand code execution system 110 and tothereafter request execution of that code. In one embodiment, therequest interface communicates with external computing devices (e.g.,user computing devices 102, auxiliary services 106, etc.) via agraphical user interface (GUI), CLI, or API. The frontends 120 processthe requests and makes sure that the requests are properly authorized.For example, the frontends 120 may determine whether the user associatedwith the request is authorized to access the user code specified in therequest.

References to user code as used herein may refer to any program code(e.g., a program, routine, subroutine, thread, etc.) written in aspecific program language. In the present disclosure, the terms “code,”“user code,” and “program code,” may be used interchangeably. Such usercode may be executed to achieve a specific function, for example, inconnection with a particular web application or mobile applicationdeveloped by the user. As noted above, individual collections of usercode (e.g., to achieve a specific function) are referred to herein as“tasks,” while specific executions of that code (including, e.g.,compiling code, interpreting code, or otherwise making the codeexecutable) are referred to as “task executions” or simply “executions.”Tasks may be written, by way of non-limiting example, in JavaScript(e.g., node.js), Java, Python, and/or Ruby (and/or another programminglanguage). Tasks may be “triggered” for execution on the on-demand codeexecution system 110 in a variety of manners. In one embodiment, a useror other computing device may transmit a request to execute a task may,which can generally be referred to as “call” to execute of the task.Such calls may include the user code (or the location thereof) to beexecuted and one or more arguments to be used for executing the usercode. For example, a call may provide the user code of a task along withthe request to execute the task. In another example, a call may identifya previously uploaded task by its name or an identifier. In yet anotherexample, code corresponding to a task may be included in a call for thetask, as well as being uploaded in a separate location (e.g., storage ofan auxiliary service 106 or a storage system internal to the on-demandcode execution system 110) prior to the request being received by theon-demand code execution system 110. As noted above, the code for a taskmay reference additional code objects maintained at the on-demand codeexecution system 110 by use of identifiers of those code objects, suchthat the code objects are combined with the code of a task in anexecution environment prior to execution of the task. The on-demand codeexecution system 110 may vary its execution strategy for a task based onwhere the code of the task is available at the time a call for the taskis processed. A request interface of the frontend 120 may receive callsto execute tasks as Hypertext Transfer Protocol Secure (HTTPS) requestsfrom a user. Also, any information (e.g., headers and parameters)included in the HTTPS request may also be processed and utilized whenexecuting a task. As discussed above, any other protocols, including,for example, HTTP, MQTT, and CoAP, may be used to transfer the messagecontaining a task call to the request interface 122.

A call to execute a task may specify one or more third-party libraries(including native libraries) to be used along with the user codecorresponding to the task. In one embodiment, the call may provide tothe on-demand code execution system 110 a file containing the user codeand any libraries (and/or identifications of storage locations thereof)corresponding to the task requested for execution. In some embodiments,the call includes metadata that indicates the program code of the taskto be executed, the language in which the program code is written, theuser associated with the call, and/or the computing resources (e.g.,memory, etc.) to be reserved for executing the program code. Forexample, the program code of a task may be provided with the call,previously uploaded by the user, provided by the on-demand codeexecution system 110 (e.g., standard routines), and/or provided by thirdparties. Illustratively, code not included within a call or previouslyuploaded by the user may be referenced within metadata of the task byuse of a URI associated with the code. In some embodiments, suchresource-level constraints (e.g., how much memory is to be allocated forexecuting a particular user code) are specified for the particular task,and may not vary over each execution of the task. In such cases, theon-demand code execution system 110 may have access to suchresource-level constraints before each individual call is received, andthe individual call may not specify such resource-level constraints. Insome embodiments, the call may specify other constraints such aspermission data that indicates what kind of permissions or authoritiesthat the call invokes to execute the task. Such permission data may beused by the on-demand code execution system 110 to access privateresources (e.g., on a private network). In some embodiments, individualcode objects may also be associated with permissions or authorizations.For example, a third party may submit a code object and designate theobject as readable by only a subset of users. The on-demand codeexecution system 110 may include functionality to enforce thesepermissions or authorizations with respect to code objects.

In some embodiments, a call may specify the behavior that should beadopted for handling the call. In such embodiments, the call may includean indicator for enabling one or more execution modes in which toexecute the task referenced in the call. For example, the call mayinclude a flag or a header for indicating whether the task should beexecuted in a debug mode in which the debugging and/or logging outputthat may be generated in connection with the execution of the task isprovided back to the user (e.g., via a console user interface). In suchan example, the on-demand code execution system 110 may inspect the calland look for the flag or the header, and if it is present, the on-demandcode execution system 110 may modify the behavior (e.g., loggingfacilities) of the container in which the task is executed, and causethe output data to be provided back to the user. In some embodiments,the behavior/mode indicators are added to the call by the user interfaceprovided to the user by the on-demand code execution system 110. Otherfeatures such as source code profiling, remote debugging, etc. may alsobe enabled or disabled based on the indication provided in a call.

To manage requests for code execution, the frontend 120 can include anexecution queue (not shown in FIG. 1), which can maintain a record ofrequested task executions. Illustratively, the number of simultaneoustask executions by the on-demand code execution system 110 is limited,and as such, new task executions initiated at the on-demand codeexecution system 110 (e.g., via an API call, via a call from an executedor executing task, etc.) may be placed on the execution queue 124 andprocessed, e.g., in a first-in-first-out order. In some embodiments, theon-demand code execution system 110 may include multiple executionqueues, such as individual execution queues for each user account. Forexample, users of the on-demand code execution system 110 may desire tolimit the rate of task executions on the on-demand code execution system110 (e.g., for cost reasons). Thus, the on-demand code execution system110 may utilize an account-specific execution queue to throttle the rateof simultaneous task executions by a specific user account. In someinstances, the on-demand code execution system 110 may prioritize taskexecutions, such that task executions of specific accounts or ofspecified priorities bypass or are prioritized within the executionqueue. In other instances, the on-demand code execution system 110 mayexecute tasks immediately or substantially immediately after receiving acall for that task, and thus, the execution queue may be omitted.

As noted above, tasks may be triggered for execution at the on-demandcode execution system 110 based on explicit calls from user computingdevices 102 (e.g., as received at the request interface). Alternativelyor additionally, tasks may be triggered for execution at the on-demandcode execution system 110 based on data retrieved from one or moreauxiliary services 106 or network-based data storage services 108. Tofacilitate interaction with auxiliary services 106, the frontend 120 caninclude a polling interface (not shown in FIG. 1), which operates topoll auxiliary services 106 or data storage services 108 for data.Illustratively, the polling interface may periodically transmit arequest to one or more user-specified auxiliary services 106 or datastorage services 108 to retrieve any newly available data (e.g., socialnetwork “posts,” news articles, files, records, etc.), and to determinewhether that data corresponds to a user-established criteria triggeringexecution a task on the on-demand code execution system 110.Illustratively, criteria for execution of a task may include, but is notlimited to, whether new data is available at the auxiliary services 106or data storage services 108, the type or content of the data, or timinginformation corresponding to the data. In some instances, the auxiliaryservices 106 or data storage services 108 may function to notify thefrontend 120 of the availability of new data, and thus the pollingservice may be unnecessary with respect to such services.

In addition to tasks executed based on explicit user calls and data fromauxiliary services 106, the on-demand code execution system 110 may insome instances operate to trigger execution of tasks independently. Forexample, the on-demand code execution system 110 may operate (based oninstructions from a user) to trigger execution of a task at each of anumber of specified time intervals (e.g., every 10 minutes).

The frontend 120 can further include an output interface (not shown inFIG. 1) configured to output information regarding the execution oftasks on the on-demand code execution system 110. Illustratively, theoutput interface may transmit data regarding task executions (e.g.,results of a task, errors related to the task execution, or details ofthe task execution, such as total time required to complete theexecution, total data processed via the execution, etc.) to the usercomputing devices 102 or to auxiliary services 106, which may include,for example, billing or logging services. The output interface mayfurther enable transmission of data, such as service calls, to auxiliaryservices 106. For example, the output interface may be utilized duringexecution of a task to transmit an API request to an external service106 (e.g., to store data generated during execution of the task).

In some embodiments, the on-demand code execution system 110 may includemultiple frontends 120. In such embodiments, a load balancer (not shownin FIG. 1) may be provided to distribute the incoming calls to themultiple frontends 120, for example, in a round-robin fashion. In someembodiments, the manner in which the load balancer distributes incomingcalls to the multiple frontends 120 may be based on the location orstate of other components of the on-demand code execution system 110.For example, a load balancer may distribute calls to a geographicallynearby frontend 120, or to a frontend with capacity to service the call.In instances where each frontend 120 corresponds to an individualinstance of another component of the on-demand code execution system,such as the active pool 140A described below, the load balancer maydistribute calls according to the capacities or loads on those othercomponents. As will be described in more detail below, calls may in someinstances be distributed between frontends 120 deterministically, suchthat a given call to execute a task will always (or almost always) berouted to the same frontend 120. This may, for example, assist inmaintaining an accurate execution record for a task, to ensure that thetask executes only a desired number of times. While distribution ofcalls via a load balancer is illustratively described, otherdistribution techniques, such as anycast routing, will be apparent tothose of skill in the art.

To execute tasks, the on-demand code execution system 110 includes oneor more worker managers 140 that manage the instances used for servicingincoming calls to execute tasks. In the example illustrated in FIG. 1,each worker manager 140 manages an active pool of virtual machineinstances 154A-C, which are currently assigned to one or more users andare implemented by one or more physical host computing devices 150A-B.The physical host computing devices 150A-B and the virtual machineinstances 154A-C may further implement one or more containers 158A-F,which may contain and execute one or more user-submitted codes 160A-G.Containers are logical units created within a virtual machine instance,or on a host computing device, using the resources available on thatinstance or device. For example, each worker manager 140 may, based oninformation specified in a call to execute a task, create a newcontainer or locate an existing container 158A-F and assign thecontainer to handle the execution of the task.

The containers 156A-F, virtual machine instances 154A-C, and hostcomputing devices 150A-B may further include language runtimes, codelibraries, or other supporting functions (not depicted in FIG. 1) thatfacilitate execution of user-submitted code 160A-G. The physicalcomputing devices 150A-B and the virtual machine instances 154A-C mayfurther include operating systems 152A-B and 156A-C. In variousembodiments, operating systems 152A-B and 156A-C may be the sameoperating system, variants of the same operating system, differentoperating systems, or combinations thereof.

Although the virtual machine instances 154A-C are described here asbeing assigned to a particular user, in some embodiments, an instance154A-C may be assigned to a group of users, such that the instance istied to the group of users and any member of the group can utilizeresources on the instance. For example, the users in the same group maybelong to the same security group (e.g., based on their securitycredentials) such that executing one member's task in a container on aparticular instance after another member's task has been executed inanother container on the same instance does not pose security risks.Similarly, the worker managers 140 may assign the instances and thecontainers according to one or more policies that dictate which requestscan be executed in which containers and which instances can be assignedto which users. An example policy may specify that instances areassigned to collections of users who share the same account (e.g.,account for accessing the services provided by the on-demand codeexecution system 110). In some embodiments, the requests associated withthe same user group may share the same containers (e.g., if the usercodes associated therewith are identical). In some embodiments, a taskdoes not differentiate between the different users of the group andsimply indicates the group to which the users associated with the taskbelong.

Once a triggering event to execute a task has been successfullyprocessed by a frontend 120, the frontend 120 passes a request to aworker manager 140 to execute the task. In one embodiment, each frontend120 may be associated with a corresponding worker manager 140 (e.g., aworker manager 140 co-located or geographically nearby to the frontend120) and thus the frontend 120 may pass most or all requests to thatworker manager 140. In another embodiment, a frontend 120 may include alocation selector configured to determine a worker manager 140 to whichto pass the execution request. In one embodiment, the location selectormay determine the worker manager 140 to receive a call based on hashingthe call, and distributing the call to a worker manager 140 selectedbased on the hashed value (e.g., via a hash ring). Various othermechanisms for distributing calls between worker managers 140 will beapparent to one of skill in the art. In accordance with embodiments ofthe present disclosure, the worker manager 140 can determine a hostcomputing device 150A-B or a virtual machine instance 154A-C forexecuting a task in accordance with a recommendation from an emulationprovisioning system 170.

The on-demand code execution system 110 further includes an emulationprovisioning system 170, which implements aspects of the presentdisclosure including, for example, the determination of how to providefunctionality that may be required for a particular task. In someembodiments, the emulation provisioning system 170 includes a codeanalyzer 162, which may be invoked when the user submits code via thefrontend 120 to statically analyze submitted code and determinefunctionality that is required by the submitted code. As described inmore detail below, the code analyzer 162 may analyze the user's code andidentify, for example, API calls, operating system calls, functioncalls, or other indications of functionality that the code will requireduring execution. In various embodiments, the code analyzer 162 mayanalyze keywords, symbols, headers, directives, or other aspects of theuser's code. In further embodiments, the on-demand code execution system110 includes an execution analyzer 164, which may be invoked when theuser's code is executed to analyze the performance of the executing codeand the functionality that is actually utilized during execution of thecode. The execution analyzer 164 may identify, for example, a portion ofthe source code that requires specific functionality, but is seldom ornever reached during execution. In further embodiments, the emulationprovisioning system 170 may include a computing resource data store 176,which may store information regarding the functionality that is providedby various host computing devices 150A-B or is emulated by variousvirtual machine instances 154A-C.

As shown in FIG. 1, various combinations and configurations of hostcomputing devices 150A-B, virtual machine instances 154A-C, andcontainers 158A-F may be used to facilitate execution of user submittedcode 160A-G. In the illustrated example, the host computing device 150Aimplements two virtual machine instances 154A and 154B. Virtual machineinstance 154A, in turn, implements two containers 158A and 158B, whichcontain user-submitted code 160A and 160B respectively. Virtual machineinstance 154B implements a single container 158C, which containsuser-submitted code 160C. The host computing device 150B furtherimplements a virtual machine instance 154C and directly implementscontainers 158E and 158F, which contain user-submitted code 160F and160G. The virtual machine instance 154C, in turn, implements container158D, which contains user-submitted codes 160D and 160E. It will beunderstood that these embodiments are illustrated for purposes ofexample, and that many other embodiments are within the scope of thepresent disclosure.

While some functionalities are generally described herein with referenceto an individual component of the on-demand code execution system 110,other components or a combination of components may additionally oralternatively implement such functionalities. For example, a workermanager 140 may operate to provide functionality associated withexecution of user-submitted code as described herein with reference toan emulation provisioning system 170.

FIG. 2 depicts a general architecture of a computing system (referencedas emulation provisioning system 170) that operates to determine howfunctionality used by a particular task should be provided within theon-demand code execution system 110. The general architecture of theemulation provisioning system 170 depicted in FIG. 2 includes anarrangement of computer hardware and software modules that may be usedto implement aspects of the present disclosure. The hardware modules maybe implemented with physical electronic devices, as discussed in greaterdetail below. The emulation provisioning system 170 may include manymore (or fewer) elements than those shown in FIG. 2. It is notnecessary, however, that all of these generally conventional elements beshown in order to provide an enabling disclosure. Additionally, thegeneral architecture illustrated in FIG. 2 may be used to implement oneor more of the other components illustrated in FIG. 1. As illustrated,the emulation provisioning system 170 includes a processor 202,input/output device interfaces 204, a network interface 206, and a datastore 208, all of which may communicate with one another by way of acommunication bus. The network interface 292 may provide connectivity toone or more networks or computing systems. The processor 202 may thusreceive information and instructions from other computing systems orservices via the network 104. The processor 202 may also communicate toand from a memory 280 and further provide output information for anoptional display (not shown) via the input/output device interfaces 204.The input/output device interfaces 296 may also accept input from anoptional input device (not shown).

The memory 220 may contain computer program instructions (grouped asmodules in some embodiments) that the processor 202 executes in order toimplement one or more aspects of the present disclosure. The memory 220generally includes random access memory (RAM), read only memory (ROM)and/or other persistent, auxiliary or non-transitory computer readablemedia. The memory 220 may store an operating system 222 that providescomputer program instructions for use by the processor 202 in thegeneral administration and operation of the emulation provisioningsystem 170. The memory 220 may further include computer programinstructions and other information for implementing aspects of thepresent disclosure. For example, in one embodiment, the memory 220includes a user interface module 224 that generates user interfaces(and/or instructions therefor) for display upon a computing device,e.g., via a navigation and/or browsing interface such as a browser orapplication installed on the computing device. In addition, the memory220 may include and/or communicate with one or more data repositories(not shown), for example, to access user program codes and/or libraries.

In addition to and/or in combination with the user interface module 224,the memory 220 may include a code analyzer 172 and an execution analyzer174 that may be executed by the processor 202. In one embodiment, thecode analyzer 172 and the execution analyzer 174 individually orcollectively implement various aspects of the present disclosure, e.g.,analyzing code or code execution to determine needed functionality andprovide that functionality efficiently, as described further below.

While the code analyzer 172 and the execution analyzer 174 are shown inFIG. 2 as part of the emulation provisioning system 170, in otherembodiments, all or a portion of the code analyzer 172 and the executionanalyzer 174 may be implemented by other components of the on-demandcode execution system 110 and/or another computing device. For example,in certain embodiments of the present disclosure, another computingdevice in communication with the on-demand code execution system 110 mayinclude several modules or components that operate similarly to themodules and components illustrated as part of the emulation provisioningsystem 170.

The memory 220 may further include user-submitted code 160, which may beloaded into memory in conjunction with a user-submitted request toexecute a task on the on-demand code execution system 110. The code 160may be illustratively analyzed by the code analyzer 172 to identifyneeded functionality, as described in more detail below. The memory 220may further include execution performance metrics 226, which may becollected from physical or virtual machines as the code 160 is executedon these platforms, and may be analyzed by the execution analyzer 174.

In some embodiments, the emulation provisioning system 170 may furtherinclude components other than those illustrated in FIG. 2. For example,the memory 220 may further include computing resource information thatidentifies the functionality provided by various physical and virtualcomputing resources that are available for executing the user-submittedcode 160, or may include metadata or other information that wassubmitted with the request, such as an indication that theuser-submitted code 160 was compiled for execution on a computingresource that provided certain functionality. FIG. 2 is thus understoodto be illustrative but not limiting.

FIG. 3 depicts illustrative interactions for determining the computingresources to use when executing a task based on an analysis of theuser-submitted code for the task. At (1), a user device 102 submits arequest to execute a task to a frontend 120 of an on-demand codeexecution system. The request may include user-submitted code, or insome embodiments may identify user code that has been previouslysubmitted. At (2), the frontend 120 requests that the code analyzer 172analyze the user-submitted code to identify functionality that the codemay require during execution. Illustratively, the user-submitted codemay take advantage of a particular instruction set if it is available,such as an instruction set that implements vector instructions, floatingpoint instructions, fused multiply-add instructions, neural networkinstructions, tensor processing instructions, single instructionmultiple data (“SIMD”) instructions, cryptography instructions, or thelike. A physical processor may implement one or more these instructionsets. A virtual processor in a virtual machine may also implement one ormore of these instruction sets, with varying performance resultsdepending on the interactions between the virtual machine and theunderlying physical computing resources.

At (3), the code analyzer 172 may request computing resource data fromthe computing resource data store 176. The computing resource data mayindicate, for example, particular computing resources that are availablewithin the on-demand code execution system 110 for executing theuser-submitted code, and may further indicate the functionalityassociated with these computing resources, the performance of thesecomputing resources when providing specified functionality, and otherparameters or information that enable the code analyzer 172 to determinerecommended computing resources. At (4), the computing resource datastore 176 may provide the requested computing resource data. In someembodiments, the computing resource data store 176 may only provide dataregarding available computing resources. In other embodiments, thecomputing resource data store 176 may provide data regarding computingresources that are unavailable (e.g., because they are currently beingused to execute other user-submitted code), and the code analyzer 172may determine whether to make these resources available by, for example,migrating other tasks.

At (5), the code analyzer 172 may determine a set of computing resourcesto use when executing the user-submitted code. In some embodiments, thecode analyzer 172 may generate a recommendation that the worker manager140 may optionally implement, depending on resource availability,prioritization of requested tasks, and other factors. In otherembodiments, the code analyzer 172 may consider some or all of thesefactors when making its determination, and may determine a set ofcomputing resources for the worker manager 140 to allocate. The codeanalyzer 172 may analyze instructions, operations, functions, API calls,libraries, or other aspects of the user-submitted code to identifyfunctionality that the code may use, and may identify computingresources that provide this functionality. For example, the codeanalyzer 172 may analyze the user-submitted code and identify that ithas been compiled for execution on a particular processor (e.g., bysetting particular flags at compile time), or that it includes a librarythat makes frequent use of floating point arithmetic. In someembodiments, the code analyzer 172 may obtain information regardingprevious executions of the user-submitted code and determine thefunctionality used by the code on that basis. In further embodiments,the code analyzer 172 may obtain information regarding other codesubmitted by the same user, and may assess whether the user'ssubmissions frequently make use of particular functionality. The codeanalyzer 172 may further analyze data such as user priorities orpreferences, and may analyze computing resource data to consider factorssuch as limited availability of particular resources (which may beexpressed as a resource cost), overall demand for certain computingresources, prioritization of requests and tasks, or otherconsiderations.

At (6), the code analyzer 172 provides the resource recommendation tothe frontend 120, and at (7) the frontend 120 provides the resourcerecommendation and the user-submitted code to the worker manager 140. Insome embodiments, the interaction at (6) may be omitted and the codeanalyzer 172 may provide a resource recommendation directly to theworker manager 140. In further embodiments, the interactions at (6) and(7) may be combined and the code analyzer 172 may provide both theuser-submitted code and the recommendation to the worker manager 140. Instill further embodiments, the worker manager 140 may carry out theinteraction at (2) and request a resource recommendation from the codeanalyzer 172. In various embodiments, the frontend 120 or the codeanalyzer 172 may provide an identifier or other information that allowsthe worker manager 140 to obtain the user-submitted code rather thanproviding the user-submitted code directly.

At (8), in some embodiments, the worker manager 140 may determine theavailability of resources that were recommended by the code analyzer172. In some embodiments, the code analyzer 172 may provide aprioritized or ordered list of potential computing resources forexecuting the user-submitted code, and the worker manager 140 maydetermine a “best available” resource by comparing the prioritized listto the available resource pool. The other embodiments, the code analyzer172 may provide scores or weighting factors for various potentialcomputing resources (or for the relative priority of the task), and theworker manager 140 may determine a computing resource based on thesefactors. In further embodiments, as described above, the code analyzer172 may consider resource availability when determining a set ofcomputing resources, and the interaction at (8) may be omitted or may bea determination that tasks must be migrated from one resource to anotherto free up the resources that will be used to execute the newlysubmitted task.

At (9), the worker manager 140 may allocate the computing resources thatwill be used to execute the user-submitted code. In various embodiments,allocating the computing resources may include allocating a hostcomputing device 150A, allocating an existing virtual machine instance(not shown in FIG. 3), instantiating a new virtual machine instance (notshown in FIG. 3), or combinations thereof. In some embodiments, asdescribed above, the worker manager 140 may allocate computing resourcesother than those recommended by the code analyzer 142. For example, ifthe computing resources recommended by the code analyzer 142 are notavailable, then the worker manager 140 may determine alternate resourcesbased on the recommendation or on resource availability. At (10), thehost computing device 150A or other allocated computing resourceexecutes the user-submitted code.

In some embodiments, the ordering and implementation of operationsdescribed above may be modified, or these interactions may be carriedout by additional or alternative elements of the on-demand codeexecution system 110. For example, in some embodiments, the workermanager 140 may be configured to analyze performance metrics and requesta resource recommendation from the execution analyzer 174 in response tothe metrics satisfying certain criteria. As a further example, codeanalysis may be carried out prior to receiving a request to executeuser-submitted code, and the results of such analysis may be stored(e.g., in the computing resource data store 176) for later use when codeexecution is requested.

FIG. 4 depicts illustrative interactions for determining the computingresources to use when executing a task based on an analysis of a currentor previous execution of the task. At (1), a computing resource that isexecuting the task, such as a host computing device 150A or a virtualmachine instance executing on the host computing device 150A, collectsperformance metrics regarding the execution of the task. Performancemetrics may include, for example, the number of processor instructionsexecuted per clock cycle, which may provide an indication of howefficiently a virtual machine instance is emulating a processor that isnot physically provided. In various embodiments, performance metrics mayinclude measurements such as total execution time, computing resourcesutilized (or not utilized) during execution, and the like. At (2), thecomputing resource reports the execution metrics to the executionanalyzer 174. In various embodiments, the computing resource may reportmetrics during execution of the task or after its completion.

At (3), the execution analyzer 174 may determine recommended computingresources. Illustratively, the execution analyzer 174 may determine,based on the execution metrics, that a different set of computingresources could execute the code more efficiently. For example, theexecution analyzer 174 may determine that the code is performing anumber of operations that would execute more efficiently on a differentcomputing resource (e.g., a processor that implements a particularinstruction set). As a further example, the execution analyzer 174 maydetermine that the code is making little or no use of a computingresource, and thus may be migrated to a different computing resourcewithout significant effect on performance. In some embodiments, theexecution analyzer 174 may obtain information from the computingresource data store 176 regarding other computing resources that may beavailable for executing the code, and may estimate the performance ofexecuting the code on those resources relative to the receivedperformance metrics.

At (4), the execution analyzer 174 may store updated computing resourcedata to the computing resource data store 176. Illustratively, theexecution analyzer 174 may store that a particular set of computingresources executed the code with a particular degree of efficiency (orinefficiency) based on the collected performance metrics, and thisinformation may be used to refine subsequent analyses by the executionanalyzer 174 or the code analyzer 172. In some embodiments, as discussedabove, the execution analyzer 174 may store that the computing resourceswere underutilized, or that particular functionality was needed butabsent, when executing the code. In some embodiments, the executionanalyzer 174 may analyze the results of multiple executions of varioususer-submitted code to identify trends or patterns that may facilitateallocation of computing resources to the execution of user-submittedcode.

At (5), in some embodiments, the execution analyzer 174 may provide anupdated resource recommendation to the worker manager 140. In someembodiments, as discussed above, the execution analyzer 174 may considerfactors such as resource availability and prioritization, and mayinstruct the worker manager 140 to migrate the user-submitted code to adifferent set of computing resources. In other embodiments, theexecution analyzer 174 may provide a recommendation and the workermanager 140 may determine whether to implement the recommendation. Insuch embodiments, at (6), the worker manager 140 may determine whethercomputing resources or available, or can be made available, to implementthe recommendation of the execution analyzer 174. In some embodiments,the worker manager 140 or the execution analyzer 174 may considerwhether the estimated performance gain to be realized by migratingexecuting code to a different set of computing resources outweighs anycosts associated with the migration, such as the transfer of executionstates or costs associated with freeing up the resources. In furtherembodiments, the worker manager 140 or the execution analyzer 174 mayaggregate or prioritize recommendations to ensure that resources areallocated efficiently overall.

At (7), the worker manager 140 may migrate execution of theuser-submitted code from one set of computing resources to another. Forexample, the worker manager 140 may migrate execution of the code from ahost computing device 150A to another host computing device 150B thatimplements different functionality. In various embodiments, the workermanager 140 may migrate the code execution from one physical computingdevice to another, from one virtual machine instance to another, from aphysical computing device to a virtual machine instance (or vice versa),or combinations thereof. In some embodiments, the worker manager 140 maymigrate the code execution by suspending execution on the host computingdevice 150A, migrating the code and state information to the hostcomputing device 150B, and then resuming code execution on the hostcomputing device 150B and releasing the resources on the host computingdevice 150A that were executing the code. In other embodiments, theworker manager 140 may migrate the code execution by terminating anin-progress execution on the host computing device 150A and startingover on the host computing device 150B. In further embodiments, theworker manager may perform a “live” migration, and may begin executionon the host computing device 150B without suspending execution on thehost computing device 150A, or may execute on both devices 150A-B inparallel for a time before completing the migration. Other embodimentsof migrating executing code will be understood to be within the scope ofthe disclosure. At (8), the host computing device 150A may suspend itsexecution of the user-submitted code, and at (9) the host computingdevice 150B (or other physical or virtual computing device) may resumeexecution of the code from the point at which execution was suspended.

In some embodiments, the execution analyzer 174 may determine a set ofcomputing resources to be used when the user-submitted code is nextexecuted, and may provide this recommendation to the code analyzer 172,worker manager 140, or store it in the computing resource data store176. Additionally, in some embodiments, the execution analyzer 174 maymake a determination or recommendation at the start of a subsequentexecution of the code based on performance metrics collected during theprevious execution(s), which may supplement or replace a code-basedanalysis for the subsequent executions.

In some embodiments, the reporting of execution metrics at (2) may becarried out continuously during execution of the user-submitted code,and the execution analyzer 174 may dynamically analyze whether theuser-submitted code requires different computing resources at variouspoints during its execution. For example, the execution analyzer 174 maydetermine that the user-submitted code has begun or ended a phase ofexecution that makes us of certain functionality, and may recommendmaking that functionality available or indicate the functionality is nolonger required. Additionally, in some embodiments, the worker manager140 may request that the execution analyzer 174 provide a recommendationfor a particular computing resource (e.g., a computing resource that hasbecome available), and may receive a recommendation to migrate executionof a particular user-submitted code to the resource.

FIG. 5 is a flow diagram of an illustrative routine 500 for determininga set of computing resources to recommend based on an analysis ofuser-submitted code. The routine 500 may be carried out, for example, bythe code analyzer 172 of FIG. 1. The routine 500 begins at block 502,where code for a task (e.g., as submitted by a user) may be obtained. Inone embodiment, the code for the task is represented as a code object,such as a compressed file including source code for the task. At block504, the code is analyzed to identify functionality that may be requiredduring code execution. As described above, the code may be analyzed withregard to libraries, programming language features, API calls, or otherfeatures to identify functionality that may be advantageous to provideduring code execution. In some embodiments, the code may be compared toother code executed by the on-demand code execution system 110, andcommon features or similarities may be identified.

At block 506, available computing resources may be identified. In someembodiments, as described above, computing resources may be identifiedregardless of their availability. In various embodiments, availabilitymay be considered both in terms of availability within a particular datacenter (e.g., the resources are present) and availability for use (e.g.,the resources are idle or can be freed). At block 508, sets of computingresources that provide the identified functionality may be identified aspotential candidates for executing the user-submitted code. A set ofcomputing resources may include, for example, various physical orvirtual resources such as a processor, memory, interfaces, data stores,and the like. In some embodiments, a virtual computing resource may beassociated with a particular host computing environment. For example, avirtual processor may be associated with the underlying physicalprocessor in order to assess the performance of the virtual processorwhen providing the required functionality.

At block 510, a set of resources that has not yet been analyzed by thisexecution of the routine 500 may be selected. At block 512, theperformance of this set of resources may be estimated with regard toexecuting the user-submitted code. The performance may be estimated, forexample, based on benchmarks, metrics, previous executions, or othercriteria. In various embodiments, performance estimates may be expressedin terms of numerical scores, grades, categories (e.g., high, medium,and low), or other formats that enable comparison.

At decision block 514, a determination may be made as to whether all ofthe candidate sets of computing resources have been analyzed by theroutine 500. If not, then the routine 500 branches to block 510 anditerates through blocks 512 and 514 until all sets of computingresources have been analyzed. Once all resource sets have been analyzed,the routine 500 branches to block 516, where a recommended set ofcomputing resources may be determined based on the performanceestimates. In some embodiments, the set of computing resources havingthe highest estimated performance may be recommended. In otherembodiments, the sets of computing resources may be associated withcost, scarcity, or other criteria that may be factored into therecommendation. For example, a scarce computing resource may beallocated only if the difference in performance relative to a widelyavailable computing resource exceeds a threshold.

At block 518, the code may be executed using the recommended set ofcomputing resources. In some embodiments, as described above, therecommended set of computing resources may be one factor in theallocation of computing resources, and may be weighed along with otherconsiderations such as resource availability or cost. In otherembodiments, a prioritized list of candidate computing resources may beoutput and may be used to determine the computing resources to use whenexecuting the code. In further embodiments, the routine 500 maydetermine that a particular resource should be made available, and mayidentify another task (and associated user-submitted code) to migrate inorder to free the particular resource based on the estimated or measuredperformance of various tasks that are executing on the resource to bemade available.

FIG. 6 is a flow diagram of an illustrative routine 600 for determininga set of computing resources to recommend based on an analysis ofexecution performance metrics. The routine 600 may be carried out, forexample, by the execution analyzer 174 of FIG. 1. The routine 600 beginsat block 602, where performance metrics may be obtained relating to theexecution of user-submitted code for a specified task on a particularset of computing resources. In some embodiments, as described above, theperformance metrics may be obtained during execution of the code. Infurther embodiments, performance metrics may be obtained periodically,in response to various events (e.g., computing resources becomingavailable or unavailable, the code invoking a particular library or APIcall, etc.), or based on other criteria. In other embodiments, theperformance metrics may be obtained after the code has completed anexecution.

At block 604, the performance metrics may be analyzed. In someembodiments, the performance metrics may be compared to a threshold orother criterion to assess whether the performance of the set ofcomputing resources is satisfactory. For example, the performancemetrics may be used to assess whether a number of instructions executedper clock cycle satisfies a threshold, or to assess whether codeexecution is completed within a time interval. In other embodiments, theperformance metrics may be analyzed relative to other performancemetrics, such as metrics obtained when executing the same or similarcode on a different set of computing resources, metrics obtained whenexecuting other code on the same set of computing resources, or anaverage or baseline performance metric.

At decision block 606, a determination may be made as to whether therelative performance of the set of computing resources when executingthe user-submitted code is acceptable. If the relative performance iscomparable to or better than a baseline, then the routine 600 may endwithout taking any measures to improve performance. In some embodiments,the routine 600 may branch to block 618 and store performance metrics orother information if the relative performance is better than average,and may use this information when making further recommendations as towhich computing resources to use when executing user-submitted code fora particular task. In other embodiments, the routine 600 may branch toblock 608 and consider migrating the task to other computing resourcesif the relative performance is higher than it needs to be. For example,the user may require that a particular task be completed within aspecified amount of time, and the set of computing resources may enablecompletion of the task far more quickly than the user requires. Thedetermination at decision block 606 may thus be that the task could becompleted on a slower set of computing resources and still meet theuser's performance requirements, and so the task should be migrated inorder to free up the faster computing resources for more time-criticaltasks.

If the determination at decision block 606 is that execution of theuser-submitted code should be migrated to a different set of computingresources, then the routine 600 branches to block 608, where availablecomputing resources may be identified. At block 610, the availablecomputing resources may be analyzed to identify an alternate set ofcomputing resources that may be used to execute the task, and at block612 the performance of the alternate set of computing resources whenexecuting the task may be estimated. In some embodiments, multiple setsof computing resources may be identified and analyzed, and block 612 maybe carried out iteratively for each candidate set. In other embodiments,an alternate set of computing resources may be identified based on therelative performance of the current set of computing resources.

At decision block 614, a determination may be made as to whetherexecution of the user-submitted code should be migrated from the currentset of computing resources to the alternate set of computing resources.In some embodiments, the determination may be as to whether thealternate set of computing resources would provide better performancebased on the obtained and estimated performance metrics. For example,the determination may be that the alternate set of computing resourceswould execute more instructions per clock cycle than the current set ofcomputing resources, and thus would lead to an improvement inperformance. In other embodiments, the determination may as to whetherthe alternate set of computing resources provides acceptable performancebased on criteria such as execution time, cost, resource utilization, orother metrics. In these embodiments, the current set of computingresources may provide higher performance than the current set ofcomputing resources, but the other factors discussed above may lead to adetermination to use the alternate set of computing resources. If thedetermination at decision block 614 is that the execution should not bemigrated, then the routine 600 ends.

If the determination at decision block 614 is that the code executionshould be migrated, then at block 616 the code execution is migrated tothe alternate set of computing resources. At block 618, the obtained orestimated performance metrics may be stored to improve the accuracy ofestimate or improve decision-making when initially allocating computingresources, as discussed above. The routine 600 then ends.

The blocks of the routines described above may vary in embodiments ofthe present disclosure. For example, in some implementations of eitherroutine, the identification of available computing resources may bedeferred or delegated to the worker manager 140, and the routine 500 or600 may provide a recommendation that the worker manager 140 determineswhether to implement, based on factors such as resource availability andthe cost-benefit of migrating tasks from one set of resources toanother. The routines may further include additional blocks, or theblocks of the routines may be rearranged, according to variousembodiments.

It is to be understood that not necessarily all objects or advantagesmay be achieved in accordance with any particular embodiment describedherein. Thus, for example, those skilled in the art will recognize thatcertain embodiments may be configured to operate in a manner thatachieves or optimizes one advantage or group of advantages as taughtherein without necessarily achieving other objects or advantages as maybe taught or suggested herein.

All of the processes described herein may be embodied in, and fullyautomated via, software code modules, including one or more specificcomputer-executable instructions, that are executed by a computingsystem. The computing system may include one or more computers orprocessors. The code modules may be stored in any type of non-transitorycomputer-readable medium or other computer storage device. Some or allthe methods may be embodied in specialized computer hardware.

Many other variations than those described herein will be apparent fromthis disclosure. For example, depending on the embodiment, certain acts,events, or functions of any of the algorithms described herein can beperformed in a different sequence, can be added, merged, or left outaltogether (e.g., not all described acts or events are necessary for thepractice of the algorithms). Moreover, in certain embodiments, acts orevents can be performed concurrently, e.g., through multi-threadedprocessing, interrupt processing, or multiple processors or processorcores or on other parallel architectures, rather than sequentially. Inaddition, different tasks or processes can be performed by differentmachines and/or computing systems that can function together.

The various illustrative logical blocks and modules described inconnection with the embodiments disclosed herein can be implemented orperformed by a machine, such as a processing unit or processor, adigital signal processor (DSP), an application specific integratedcircuit (ASIC), a field programmable gate array (FPGA) or otherprogrammable logic device, discrete gate or transistor logic, discretehardware components, or any combination thereof designed to perform thefunctions described herein. A processor can be a microprocessor, but inthe alternative, the processor can be a controller, microcontroller, orstate machine, combinations of the same, or the like. A processor caninclude electrical circuitry configured to process computer-executableinstructions. In another embodiment, a processor includes an FPGA orother programmable device that performs logic operations withoutprocessing computer-executable instructions. A processor can also beimplemented as a combination of computing devices, e.g., a combinationof a DSP and a microprocessor, a plurality of microprocessors, one ormore microprocessors in conjunction with a DSP core, or any other suchconfiguration. Although described herein primarily with respect todigital technology, a processor may also include primarily analogcomponents. A computing environment can include any type of computersystem, including, but not limited to, a computer system based on amicroprocessor, a mainframe computer, a digital signal processor, aportable computing device, a device controller, or a computationalengine within an appliance, to name a few.

Conditional language such as, among others, “can,” “could,” “might,” or“may,” unless specifically stated otherwise, are otherwise understoodwithin the context as used in general to convey that certain embodimentsinclude, while other embodiments do not include, certain features,elements and/or steps. Thus, such conditional language is not generallyintended to imply that features, elements and/or steps are in any wayrequired for one or more embodiments or that one or more embodimentsnecessarily include logic for deciding, with or without user input orprompting, whether these features, elements and/or steps are included orare to be performed in any particular embodiment.

Disjunctive language such as the phrase “at least one of X, Y, or Z,”unless specifically stated otherwise, is otherwise understood with thecontext as used in general to present that an item, term, etc., may beeither X, Y, or Z, or any combination thereof (e.g., X, Y, and/or Z).Thus, such disjunctive language is not generally intended to, and shouldnot, imply that certain embodiments require at least one of X, at leastone of Y, or at least one of Z to each be present.

Any process descriptions, elements or blocks in the flow diagramsdescribed herein and/or depicted in the attached figures should beunderstood as potentially representing modules, segments, or portions ofcode which include one or more executable instructions for implementingspecific logical functions or elements in the process. Alternateimplementations are included within the scope of the embodimentsdescribed herein in which elements or functions may be deleted, executedout of order from that shown, or discussed, including substantiallyconcurrently or in reverse order, depending on the functionalityinvolved as would be understood by those skilled in the art.

Unless otherwise explicitly stated, articles such as “a” or “an” shouldgenerally be interpreted to include one or more described items.Accordingly, phrases such as “a device configured to” are intended toinclude one or more recited devices. Such one or more recited devicescan also be collectively configured to carry out the stated recitations.For example, “a processor configured to carry out recitations A, B, andC” can include a first processor configured to carry out recitation Aworking in conjunction with a second processor configured to carry outrecitations B and C.

What is claimed is:
 1. A system comprising: a non-transitory data storestoring information regarding physical and virtual processors, theinformation identifying, for each processor of the physical and virtualprocessors, an instruction set implemented by the processor from among aplurality of instruction sets implemented among the physical and virtualprocessors; and a computing device configured with executableinstructions to: receive user-submitted code executable on an on-demandcode execution system; identify an instruction set, from the pluralityof instruction sets, associated with the user-submitted code, whereinthe user-submitted code utilizes the instruction set when executed onthe on-demand code execution system; and in response to a request toexecute the user-submitted code: obtain availability informationregarding a physical processor from the physical processors, thatimplements the instruction set; obtain first performance informationregarding the physical processor; obtain second performance informationregarding a virtual processor, from the virtual processors, thatimplements the instruction set; determine, based at least in part on theavailability information, the first performance information, and thesecond performance information, a recommended processor for executingthe user-submitted code, wherein the recommended processor is one of thephysical processor and the virtual processor; and cause the on-demandcode execution system to execute the user-submitted code on therecommended processor.
 2. The system of claim 1, wherein the instructionset comprises a vector instruction set, floating point instruction set,fused multiply-add instruction set, neural network instruction set,tensor processing instruction set, single instruction multiple datainstruction set, security instruction set, or cryptography instructionset.
 3. The system of claim 1, wherein the instruction set is identifiedbased at least in part on a software library invoked by theuser-submitted code.
 4. The system of claim 1, wherein the secondperformance information is associated with instantiating the virtualprocessor on a physical processor that does not implement theinstruction set.
 5. The system of claim 1, wherein the user-submittedcode is compiled for the physical processor.
 6. A computer-implementedmethod comprising: receiving user-submitted code executable on anon-demand code execution system; determining, based at least in part onthe user-submitted code, computing resource functionality associatedwith executing the user-submitted code on the on-demand code executionsystem; and in response to a request to execute the user-submitted code:obtaining first performance information regarding a first computingresource that physically implements the computing resourcefunctionality; obtaining second performance information regarding asecond computing resource that does not physically implement thecomputing resource functionality but that virtually emulates thecomputing resource functionality; determining, based at least in part onthe first performance information and the second performanceinformation, a recommended computing resource for executing theuser-submitted code, the recommended computing resource being one of thefirst computing resources or the second computing resource; andproviding a recommendation that includes the recommended computingresource to the on-demand code execution system, wherein the on-demandcode execution system selects a computing resource for executing theuser-submitted code based at least in part on the recommendation.
 7. Thecomputer-implemented method of claim 6, wherein at least one of thefirst performance information and the second performance information wasgenerated during a previous execution of the user-submitted code on theon-demand code execution system.
 8. The computer-implemented method ofclaim 6 further comprising: obtaining, from the on-demand code executionsystem, performance metrics regrading execution of the user-submittedcode with the selected computing resource; identifying, based at leastin part on the performance metrics, an alternate computing resource; andproviding an updated recommendation that includes the alternatecomputing resource to the on-demand code execution system, whereinproviding the updated recommendation causes the on-demand code executionsystem to migrate execution of the user-submitted code to a differentcomputing resource.
 9. The computer-implemented method of claim 8,wherein the performance metrics include a number of processorinstructions executed per clock cycle.
 10. The computer-implementedmethod of claim 8 further comprising determining that the alternatecomputing resource is available.
 11. The computer-implemented method ofclaim 6, wherein the first computing resource is a physical computingresource and the second computing resource is a virtual computingresource.
 12. The computer-implemented method of claim 6 furthercomprising identifying, based at least in part on the computing resourcefunctionality associated with executing the user-submitted code, thefirst computing resource and the second computing resource.
 13. Thecomputer-implemented method of claim 6 further comprising aggregating aplurality of previous recommendations for computing resources todetermine a recommended hardware configuration for the on-demand codeexecution system.
 14. The computer-implemented method of claim 13,wherein the recommended hardware configuration is based at least in parton one or more trends in the plurality of previous recommendations. 15.The computer-implemented method of claim 13, wherein the recommendedhardware configuration is based at least in part on performance metrics.16. The computer-implemented method of claim 6, wherein the firstcomputing resource implements the computing resource functionality byemulating the computing resource functionality.
 17. Non-transitorycomputer-readable media including computer-executable instructions that,when executed by an on-demand code execution system, cause the on-demandcode execution system to: obtain user-submitted code executable on theon-demand code execution system; determine, based at least in part onthe user-submitted code, computing resource functionality associatedwith executing the user-submitted code on the on-demand code executionsystem, wherein the on-demand code execution system does not receive arequest to provide the computing resource functionality; identifying aplurality of computing resources that implement the computing resourcefunctionality; in response to a request to execute the user-submittedcode: identifying an available subset of the plurality of computingresources that either physically implement or virtually emulate thecomputing resource functionality; selecting, from the available subset,a recommended computing resource for executing the user-submitted codebased at least in part on performance of individual computing resourcesin the available subset at providing the computing resourcefunctionality; and executing the user-submitted code on the recommendedcomputing resource.
 18. The non-transitory computer-readable media ofclaim 17 including further computer-executable instructions that, whenexecuted by the on-demand code execution system, cause the on-demandcode execution system to generate a prioritized list of computingresources based at least in part on performance estimates for individualcomputing resources in the plurality of computing resources.
 19. Thenon-transitory computer-readable media of claim 17 including furthercomputer-executable instructions that, when executed by the on-demandcode execution system, cause the on-demand code execution system todetermine, based at least in part on a performance estimate for anunavailable computing resource, to migrate at least one other task tomake the unavailable computing resource available.
 20. Thenon-transitory computer-readable media of claim 17, wherein the requestto execute the user-submitted code specifies a preferred computingresource for executing the user-submitted code, and wherein thepreferred computing resource does not provide the computing resourcefunctionality.
 21. The non-transitory computer-readable media of claim20, wherein the recommended computing resource is determined based atleast in part on comparing a performance estimate for executing theuser-submitted code on the recommended computing resource to aperformance estimate for executing the user-submitted code on thepreferred computing resource.